Accusoft.BarcodeXpress.nodejs
Tutorial: Create Your First Project

This step-by-step tutorial will guide you to build a complete application that analyzes a Code 39 barcode from an image and output the value, type, location and confidence to the terminal.

Prerequisites:

For this tutorial, you can use any text editor (vim, gedit, emacs, etc.).

Steps:

  1. Create a new file titled BXDemo.js
  2. Import the Barcode module:
    Copy Code
    var bx = require('barcode-js');
    
  3. Add some code to display a message that the sample is starting:
    Copy Code
    console.log('\n...... Begin tutorial .........\n');
    
  4. Create the parameters to use for recognition - namely, the input image and the language to recognize:
    Copy Code
    var params = {
        input: 'filePath/fileName.bmp',
        type: 'code39'
    };
    
  5. Modify the "input" image path to an image on your local system.
    • Simply replace the text "/path/to/image/file.bmp" with an image on your local system.
  6. Perform analyze on your barcode image:
    Copy Code
    bx.analyze(params, function (err, results) {
        if (err) {
            console.error("There was an error processing this image", err);
            return;
        }
        results.forEach(function(result) {
            console.log ('Result type ' + result.type);
            console.log ('\t' + 'value ' + result.value);
        });   
    });
    
  7. That’s it! Now go to the console and run your application to see the result output data:
    Copy Code
    $ node BXDemo
    

 

 

 


©2016. Accusoft Corporation. All Rights Reserved.

Send Feedback